package com.hx.vending.controller;

import com.hx.vending.annotation.AnnotationField;
import com.hx.vending.annotation.Authorization;
import com.hx.vending.annotation.CurrentFieldId;
import com.hx.vending.annotation.CurrentUserId;
import com.hx.vending.bean.Medicine;
import com.hx.vending.service.IMedicineService;
import com.hx.vending.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2019/3/12.
 */
@Controller
@RequestMapping("/medicine")
public class MedicineController {

    @Autowired
    private IMedicineService medicineService;

    /**
     * 查询病区记录
     * @param userId
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectMedicine")
    @Authorization
    @AnnotationField
    public Msg selectMedicine(@CurrentUserId Integer userId,@CurrentFieldId Integer[] integers,
                              @RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum){
        pageNum = (pageNum - 1) * 10;
        List<Medicine> medicineList = medicineService.selectByExamplePage(userId,integers,pageNum);
        return Msg.success().add("medicineList",medicineList);
    }

}
